{template 'common/header'}
<ul class="nav nav-tabs">
    <li><a href="{php echo $this->createWebUrl('agent');}">分销商管理</a></li>
	<li {if $_GPC['do']=='commission' && $op=='commissionlog'} class="active"{/if}><a href="{php echo $this->createWebUrl('commission', array('op'=>'commissionlog'));}">分销奖学金明细</a></li>
	<li {if $_GPC['do']=='commission' && $op=='statis'} class="active"{/if}><a href="{php echo $this->createWebUrl('commission', array('op'=>'statis'));}">分销奖学金统计</a></li>
	<li {if $_GPC['do']=='commission' && $op=='level'} class="active"{/if}><a href="{php echo $this->createWebUrl('commission', array('op'=>'level'));}">分销商等级</a></li>
	<li><a href="{php echo $this->createWebUrl('comsetting');}">分销设置</a></li>
</ul>

{if $op=='level'}
<div class="alert alert-info">
    提示: 没有设置等级的分销商将按默认设置计算提成。商品指定的奖学金金额的优先级仍是最高的，也就是说只要商品指定了奖学金金额就按商品的奖学金金额来计算，不受等级影响
</div>
<form action="" method="post" onsubmit="return formcheck(this)">
	<div class="panel panel-default">
		<div class="panel-heading">
			分销商等级设置
		</div>
		<div class="panel-body">
			<table class="table">
				<thead>
					<tr>
						<th style="width:10%;">等级名称</th>
                        <th style="width:10%;">一级比例</th>
						<th style="width:10%;">二级比例</th>
						<th style="width:10%;">三级比例</th>
						<th style="width:20%;">升级条件</th>
                        <th style="width:15%;">操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $level}
					<tr>
						<td>{$level['levelname']}</td>
                        <td>{$level['commission1']}%</td>
						<td>{$level['commission2']}%</td>
						<td>{$level['commission3']}%</td>
						<td>
						{if $level['updatemoney']>0}
							{if $comsetting['upgrade_condition']==1}分销累计奖学金
							{elseif $comsetting['upgrade_condition']==2}购买订单总额
							{elseif $comsetting['upgrade_condition']==3}购买订单
							{/if}
							满 {$level['updatemoney']}
							{if $comsetting['upgrade_condition']==1 || $comsetting['upgrade_condition']==2}元
							{elseif $comsetting['upgrade_condition']==3}单
							{/if}
						{else}
							不自动升级
						{/if}
						</td>
                        <td>
                            <a class="btn btn-default" href="{php echo $this->createWebUrl('commission', array('op'=>'editlevel', 'id'=>$level['id']));}">编辑</a>
                            <a class="btn btn-default" href="{php echo $this->createWebUrl('commission', array('op'=>'dellevel', 'id'=>$level['id']));}" onclick="return confirm('确认删除此等级吗？');return false;">删除</a>
						</td>
                    </tr>
					{/loop}
                </tbody>
            </table>
			{$pager}
         </div>
         <div class="panel-footer">
			<a class="btn btn-default" href="{php echo $this->createWebUrl('commission', array('op'=>editlevel));}"><i class="fa fa-plus"></i> 添加新等级</a>
         </div>
     </div>
</form>

{elseif $op=='editlevel'}
<div class="alert alert-info">
    提示: 没有设置等级的分销商将按默认设置计算提成。商品指定的奖学金金额的优先级仍是最高的，也就是说只要商品指定了奖学金金额就按商品的奖学金金额来计算，不受等级影响
</div>
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">
                分销商等级设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span> 等级名称</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="levelname" class="form-control" value="{$level['levelname']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>一级分销比例</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="commission1" class="form-control" value="{$level['commission1']}">
                    </div>
                </div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">二级分销比例</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="commission2" class="form-control" value="{$level['commission2']}">
                    </div>
                </div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">三级分销比例</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="commission3" class="form-control" value="{$level['commission3']}">
                    </div>
                </div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">升级条件</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="input-group">
							<span class="input-group-addon">
								{if $comsetting['upgrade_condition']==1}分销累计奖学金
								{elseif $comsetting['upgrade_condition']==2}购买订单总额
								{elseif $comsetting['upgrade_condition']==3}购买订单
								{/if}
								满
							</span>
							<input type="text" name="updatemoney" class="form-control" value="{$level['updatemoney']}">
							<span class="input-group-addon">
								{if $comsetting['upgrade_condition']==1 || $comsetting['upgrade_condition']==2}元
								{elseif $comsetting['upgrade_condition']==3}单
								{/if}
							</span>
                        </div>
                        <span class="help-block">分销商升级条件，不填写默认为不自动升级</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="id" value="{$id}">
			<input type="hidden" name="token" value="{$_W['token']}">
		</div>
    </form>
</div>

{elseif $op=='commissionlog'}
<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="fy_lessonv2" />
			<input type="hidden" name="do" value="commission" />
			<input type="hidden" name="op" value="commissionlog" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="width:100px;">会员昵称</label>
				<div class="col-sm-2 col-lg-3">
					<input class="form-control" name="nickname" type="text" value="{$_GPC['nickname']}">
				</div>
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label" style="width: 100px;">课程名称</label>
				<div class="col-sm-2 col-lg-3">
					<input class="form-control" name="bookname" type="text" value="{$_GPC['bookname']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="width:100px;">分销等级</label>
				<div class="col-sm-8 col-lg-3 col-xs-12">
					<select name="grade" class="form-control">
						<option value="">不限</option>
						<option value="1" {if $_GPC['grade'] == 1} selected="selected" {/if}>一级分销</option>
						<option value="2" {if $_GPC['grade'] == 2} selected="selected" {/if}>二级分销</option>
						<option value="3" {if $_GPC['grade'] == 3} selected="selected" {/if}>三级分销</option>
						<option value="-1" {if $_GPC['grade'] == -1} selected="selected" {/if}>管理员操作</option>
					</select>
				</div>
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label" style="width: 100px;">备注</label>
				<div class="col-sm-2 col-lg-3">
					<input class="form-control" name="remark" id="" type="text" value="{$_GPC['remark']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="width: 100px;">下单时间</label>
				<div class="col-sm-8 col-lg-3 col-xs-12">
					{php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d', $starttime),'endtime'=>date('Y-m-d', $endtime)));}
				</div>
				<div class="col-sm-3 col-lg-3" style="width: 22%;">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					<button type="submit" name="export" value="1" class="btn btn-success">导出 Excel</button>
				</div>
			</div>
		</form>
	</div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">分销奖学金明细</div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style='width:8%;'>ID</th>
                    <th style='width:10%;'>会员信息</th>
                    <th style='width:23%;'>分销课程</th>
                    <th style='width:10%;'>分销等级</th>
					<th style='width:10%;'>分销奖学金</th>
                    <th style='width:24%;'>备注</th>
                    <th style='width:15%;'>分销时间</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['id']}</td>
                    <td>{$row['nickname']}</td>
                    <td>{$row['bookname']}</td>
					<td>{if $row['grade']==1}<span class="label label-success">一级分销</span>{elseif $row['grade']==2}<span class="label label-primary">二级分销</span>{elseif $row['grade']==3}<span class="label label-warning">三级分销</span>{elseif $row['grade']==-1}<span class="label label-info">管理员操作</span>{/if}</td>
                    <td>{$row['change_num']} 元</td>
					<td>{$row['remark']}</td>
                    <td>{php echo date('Y-m-d H:i',$row['addtime']);}</td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</div>

{elseif $op=='statis'}
<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="fy_lessonv2" />
			<input type="hidden" name="do" value="commission" />
			<input type="hidden" name="op" value="statis" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="width:100px;">会员昵称</label>
				<div class="col-sm-2 col-lg-3">
					<input class="form-control" name="nickname" type="text" value="{$_GPC['nickname']}">
				</div>
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label" style="width: 100px;">会员姓名</label>
				<div class="col-sm-2 col-lg-3">
					<input class="form-control" name="realname" type="text" value="{$_GPC['realname']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="width:100px;">手机号码</label>
				<div class="col-sm-8 col-lg-3 col-xs-12">
					<input class="form-control" name="mobile" type="text" value="{$_GPC['mobile']}">
				</div>
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="width:100px;">排序依据</label>
				<div class="col-sm-8 col-lg-3 col-xs-12">
					<select name="ranking" class="form-control">
						<option value="1" {if $_GPC['ranking'] == 1} selected="selected" {/if}>累计奖学金</option>
						<option value="2" {if $_GPC['ranking'] == 2} selected="selected" {/if}>已申请奖学金</option>
						<option value="3" {if $_GPC['ranking'] == 3} selected="selected" {/if}>待申请奖学金</option>
					</select>
				</div>
				<div class="col-sm-3 col-lg-3">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>&nbsp;&nbsp;
					<button type="submit" name="export" value="1" class="btn btn-success">导出 Excel</button>
				</div>
			</div>
		</form>
	</div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">分销奖学金统计</div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style='width:8%;'>会员ID</th>
                    <th style='width:15%;'>会员昵称</th>
                    <th style='width:15%;'>会员姓名</th>
                    <th style='width:15%;'>手机号码</th>
					<th style='width:15%;'>已申请奖学金</th>
                    <th style='width:15%;'>待申请奖学金</th>
                    <th style='width:15%;'>累计奖学金</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['uid']}</td>
                    <td>{$row['nickname']}</td>
                    <td>{$row['realname']}</td>
					<td>{$row['mobile']}</td>
                    <td>{$row['pay_commission']} 元</td>
					<td>{$row['nopay_commission']} 元</td>
                    <td>{$row['total_commission']} 元</td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</div>
{/if}

{template 'common/footer'}